<?php

class CTruncate
{
    public static function trunc($str, $length = 300, $after = '...')
    {
	if (strlen($str) <= $length) {
	    return $str;
	}	
	return substr($str, 0, strpos($str, ' ', $length)) . $after;	 
    }
}